<template>
  <!-- 施工项目记录 -->
  <div>
    <table-box
      ref="constructionRecord"
      :selected-arry.sync="tableSelected"
      :table-config="tableConfig"
      :other-filters="otherFilters"
      :off-set="-20"
      show-index
      no-request
      @btnOperate="btnOperate"
    />
    <pro-evaluation-dlg v-if="showDetail" ref="dailyAssessment" :visible.sync="showDetail" :detail-data="activatedData" />
    <!-- <record-detail v-if="showDetail" ref="addFinishedPlan" :visible.sync="showDetail" :detail-data="activatedData" /> -->
  </div>
</template>

<script>
import ProEvaluationDlg from '../../unitScoreMng/component/proEvaluationDlg.vue'
// import RecordDetail from './recordDetail.vue'
export default {
  name: 'ConstructionRecord',
  components: { ProEvaluationDlg },
  props: {
    visible: {
      type: Boolean,
      default: false,
      required: true
    },
    detailData: {
      type: [String, Object],
      default: ''
    }
  },
  data() {
    return {
      showDetail: false,
      formData: {},
      activatedData: [],
      tableSelected: [],
      otherFilters: [],
      tableConfig: {
        interfacePath: `${process.env.VUE_APP_BASE_API}/api/v1/constUnitAssessScore/itemScore/page`,
        setting: [
          {
            prop: 'constCode',
            label: '门店建设项目号',
            minWidth: '100'
          },
          {
            prop: 'shopName',
            label: '门店',
            minWidth: '100'
          },
          {
            prop: 'decorationTaskCode',
            label: '装修任务',
            minWidth: '100'
          },
          {
            prop: 'expectDecorationTime',
            label: '预计进场时间',
            minWidth: '120',
            type: 'hidden'
          },
          {
            prop: 'actualApproachTime',
            label: '实际进场时间',
            minWidth: '120',
            type: 'hidden'
          },
          {
            prop: 'expectEndTime',
            label: '预计完工时间',
            minWidth: '120',
            type: 'hidden'
          },
          {
            prop: 'actualEndTime',
            label: '实际完工时间',
            minWidth: '120',
            type: 'hidden'
          },
          // {
          //   prop: 'schedule',
          //   label: '项目进度',
          //   minWidth: '100',
          //   type: 'hidden',
          //   propEnum: {
          //     domainCode: 'marketing',
          //     appCode: 'slm',
          //     dictTypeCode: 'DECORATION_SCHEDULE'
          //   }
          // },
          {
            prop: 'scoreNature',
            label: '评估性质',
            type: 'hidden',
            propEnum: {
              domainCode: 'marketing',
              appCode: 'slm',
              dictTypeCode: 'SCORE_NATURE'
            }
          },
          {
            prop: 'actualScore',
            label: '项目评分',
            minWidth: '100',
            type: 'hidden'
          }
        ],
        btnList: [{
          buttonName: '查看评估详情',
          optCode: 'check',
          outerFlag: true
        }]
      }
    }
  },
  computed: {
    dialogShow: {
      get() {
        return this.visible
      },
      set(val) {
        this.$emit('update:visible', val)
      }
    }
  },
  created() {
    this.formData = this.detailData.data
    this.otherFilters = [{ 'id': 'unitCode', 'property': 'unitCode', 'operator': '=', 'value': this.formData.unitCode }]
    this.$nextTick(() => {
      this.$refs.constructionRecord.initTableData('')
    })
  },
  activated() {},
  methods: {
    // 按钮组
    btnOperate(flag) {
      switch (flag) {
        case 'check':
          if (!this.singleJudge(this.tableSelected, '查看评估详情', false)) {
            return
          }
          this.handleCheckDetail(this.tableSelected[0])
          break
        default:
          break
      }
    },
    // 新增/编辑
    handleEdit(data) {
      this.showEdit = true
      // const obj = JSON.parse(decodeURIComponent(this.disCode))
      // this.activatedData = {}
      // if (data && data.recordId) {
      //   this.activatedData.recordId = data.recordId
      // }
      // this.activatedData.disCode = obj.orgCode
      // this.showEditDlg = true
    },
    handleCheckDetail(row) {
      this.activatedData.flag = 'unitProEvaluation'
      this.activatedData.data = row
      this.activatedData.data.unitCode = this.formData.unitCode
      this.showDetail = true
    },
    // 刷新
    refreshTable(isInit) {
      this.$refs.finishedProductPlan.initTableData(isInit ? '' : 'onPage')
    },
    goHome() {
      this.showEdit = false
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
